function _getCookie(name)
{
    var result = null;
    var p = escape(name) + "=";
    var CookieArray = document.cookie.split(';');
    for (var i = 0; i < CookieArray.length; i++) {
        var si = CookieArray[i].indexOf(p);
        if (si == 0) {
            var tmp = CookieArray[i].split('=');
            result = '';
            if (tmp[1] != null) {
                result = unescape(tmp[1]);
            }
        }
    }
    return result;
}

function setCookie (name, value, expires, path, domain, secure)
{
    document.cookie =
    (escape(name) + "=" + escape(value) +
    ((expires) ? "; expires=" + expires : "") +
    ((path) ? "; path=" + path : "") +
    //((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : ""));

    return true;
}

function getCookie(name)
{
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1) {
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return setStr;
}

function deleteCookie(name, path, domain)
{
    if (getCookie(name)) {
        document.cookie = name + "=" +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";    }
}